listbox: short-circuit if no sort function is set
authorChristian Hergert <chergert@redhat.com>
Mon, 20 Jun 2016 22:17:00 +0000 (15:17 -0700)
committerChristian Hergert <chergert@redhat.com>
Tue, 21 Jun 2016 01:51:42 +0000 (18:51 -0700)
do_sort will crash if sort_func is not defined. Instead of adding a check
there in the hot path, just check for sort_func before invalidating the
sort of the underlying GSequence.

gtk/gtklistbox.c

index 91c08e361e1bbcdf0ae93803ce37410a672f1785..17f19072ecd3eb48f0bd1d8177f101f8bd3ed345 100644 (file)
@@ -1280,6 +1280,9 @@ gtk_list_box_invalidate_sort (GtkListBox *box)
 
   g_return_if_fail (GTK_IS_LIST_BOX (box));
 
+  if (priv->sort_func == NULL)
+    return;
+
   g_sequence_sort (priv->children, (GCompareDataFunc)do_sort, box);
   g_sequence_foreach (priv->children, gtk_list_box_css_node_foreach, &previous);